package io.gitee.luoyuan800.tool.llm.bean;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import io.gitee.luoyuan800.tool.llm.bean.completion.Usage;
import lombok.Data;

import java.util.List;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Message extends AbstractMessage<String> {
    private String content;
    private String reasoningContent;
    private List<ToolCallResult> toolCalls;
    private String toolCallId;
    private String name;
    private Usage usage;
    private Long timeCost;

    @JsonIgnore
    public String getFullContent() {
        if (reasoningContent != null) {
            return "<thinking>\n" + reasoningContent + "\n</thinking>\n" + content;
        }
        return content;
    }

    @Override
    public String toString() {
        return getRole() + ": " + getContent();
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class ToolCallResult {
        private String id;
        private String type;
        private Function function;
    }

    @Data
    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Function {
        private String name;
        private String arguments;
    }
}
